class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        lastNum = None
        for i in range(len(nums)):
            if nums[i]==lastNum:
                nums[i]=None
            else:
                lastNum = nums[i]
        i, j = 0, 0
        while j < len(nums):
            if nums[j]!=None:
                nums[i]=nums[j]
                i+=1
            j+=1
        return i

nums = [1,2,3,3,3]
print(Solution().removeDuplicates(nums), nums)